<template>
  <div class="switch" @click.stop>
      <span
          class="switch-item"
          @click="networkPage"
          :class="{ current: !isApp }"
      ></span>
    <span class="switch-item" @click="appPage" :class="{ current: isApp }"></span>
  </div>
</template>

<script setup>
import { storeToRefs } from "pinia";
import { useHomeStore } from "@/stores/home";
const useStore = useHomeStore();
const { isApp } = storeToRefs(useStore);
const networkPage = () => {
  useStore.isApp = false;
};
const appPage = () => {
  useStore.isApp = true;
};
</script>

<style lang="less">
.switch {
  margin: .75rem auto 0;
  width: 90px;
  height: 20px;
  border-radius: 20px;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  cursor: pointer;
  .switch-item {
    display: block;
    width: 25px;
    height: 8px;
    background-color: #ffffff84;
    border-radius: 10px;
    cursor: pointer;
  }
  .switch-item:hover {
    background-color: #fff;
  }
  .current {
    background-color: #fff;
  }
}
.switch:hover {
  background-color: #cccccc7b;
}
@media screen and (max-width: 700px) {
  .switch {
    justify-content: space-evenly;
    width: 90px;
    height: 20px;
    //  margin: -20px auto 0;
    // margin-top: 30px;
    .switch-item {
      display: block;
      width: 25px;
      height: 7px;
      background-color: #ffffff84;
      border-radius: 10px;
      cursor: pointer;
    }
  }
}
</style>